//
//  ReleaseAdviceViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/19.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "ReleaseAdviceViewController.h"
#import "ReleaseAdviceView.h"

@interface ReleaseAdviceViewController ()
@property(nonatomic ,strong)ReleaseAdviceView *aView;
@end

@implementation ReleaseAdviceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
    //添加当前类对象为一个观察者，name和object设置为nil，表示接收一切通知
    [center addObserver:self selector:@selector(networkDidReceiveMessage:) name:@"pingjia2" object:nil];
    
    _aView=[ReleaseAdviceView new];
    [self.view addSubview:_aView];
    [_aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    _aView.viewController=self;;
    if (_dic==nil) {
        self.navigationItem.title=@"发布咨询";
        [_aView creatView];
    }
    else{
        self.navigationItem.title=@"咨询详情";
        [self loadData];
    }
}
-(void)viewWillDisappear:(BOOL)animated{
    [_aView.player stop];
}
-(void)networkDidReceiveMessage:(NSNotification *)notification{
    [ZQTools cleanViewSubviews:_aView];
    [self loadData];
}
-(void)loadData{
    
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *consult_id1=[_dic objectForKey:@"consult_id"];
    NSString *consult_id=[NSString stringWithFormat:@"%@",consult_id1];
    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:consult_id,@"consult_id",user_id,@"user_id",token,@"token",@"0",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"user/consult/consult_info" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        
        _aView.dic=responseObject;
        [_aView creatView];
        
    } anderrorBlock:nil];
    
}

-(void)popVc{
    if (_abc==1) {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
